<template>
	<view class="content">
		<view class="header">
			<view class="datebox" @click="show = true" v-show="isdate == false">
				选择日期
			</view>
			<view class="datebox" @click="show = true" v-show="isdate == true">
				{{ date.result }}
			</view>
			<view class="datebox" @click="typeshow = true">
				<view class="" v-if="typeshow1 == true">
					{{ lxtype[0].label }}
				</view>
				<view class="" v-else>
					全部
				</view>
			</view>
		</view>
		<u-calendar v-model="show" :mode="mode" @change="change">
			<view slot="tooltip">
				<view class="title">
					全部
				</view>
			</view>
		</u-calendar>
		<u-select v-model="typeshow" mode="single-column" :list="list" @confirm="confirm"></u-select>
		<view class="drboxtext">
			<view class="blancetext">
				当前余额
			</view>
			<view class="pdtxt" style="color: #FFB02E;">
				<text class="" style="font-size: 36rpx;">{{ allpd }}</text>
				<text class="" style="font-size: 24rpx;">大王币</text>
			</view>
		</view>




		<view class="neirongbox" v-for="(item, index) in recordList" :key="index" v-if="recordList != []"
			@click="gotoxq(item)">
			<view class="header-shoptxt">
				<view class="h_shoptxt">
					<view class="shoptxt" v-if="item.desc == '商品拒提' || item.desc == '购买盲盒'">
						{{ item.desc }}
					</view>
					<view class="sptitle" v-if="item.form_id == 3 || item.form_id == 1">
						{{ handleDatas(item.detail) }}
					</view>
					<view class="sptitle-desc" v-else>
						{{ item.desc }}
					</view>
				</view>
				<view class="sptitle-right" v-if="item.form_id == 3 || item.form_id == 1">
					{{ item.type == 1 ? '-' : '+' }}{{ item.num }}
				</view>
				<view class="sptitle-right" v-else>
					{{ item.type == 1 ? '-' : '+' }}{{ item.num }}
				</view>
			</view>
			<view class="footer-timetxt">
				<view class="ft-create">
					{{ item.create_time }}
				</view>
				<view class="ft-blance">
					余额：<text style="color: #FFB02E;">{{ item.after }} </text>
				</view>
			</view>
		</view>


		<u-empty text="暂无数据" mode="list" v-else></u-empty>
	</view>
</template>

<script>
export default {
	data() {
		return {
			typeshow: false,
			page: 1,
			recordList: [],
			allpd: 0,
			show: false,
			mode: 'date',
			isdate: false,
			date: {},
			lxtype: [],
			typeshow1: false,
			list: [{
				value: '1',
				label: '购买盲盒'
			},
			{
				value: '2',
				label: '平台充值'
			},
			{
				value: '3',
				label: '商品拒提'
			},
			{
				value: '4',
				label: '系统赠送'
			},
			{
				value: '6',
				label: '推广分佣'
			},
			{
				value: '10',
				label: '邀请送豆'
			},
			{
				value: '11',
				label: '商城购买商品'
			}
			],
		};
	},
	onShow() {
		this.getlist();
	},
	onPullDownRefresh() {
		this.page = 1;
		setTimeout(function () {
			uni.stopPullDownRefresh();
		}, 1000);
		clearTimeout();
		this.recordList = []
		this.getlist();
	},
	onReachBottom() {
		this.page++;
		this.getlist(2);
	},
	methods: {
		gotoxq(e) {
			if (e.form_id == 6 || e.form_id == 10) {
				return true
			} else {
				uni.navigateTo({
					url: '/userPage/user/yexiangqing?id=' + e.id
				})
			}

		},
		confirm(e) {
			this.typeshow1 = true
			// ////console.log(e);
			this.lxtype = e
			this.getlist()
		},
		change(e) {
			this.date = e
			this.isdate = true
			this.getlist()
		},
		handleDatas(str) {
			if (str?.length > 8) {
				return str.substr(0, 8) + '...';
			}
			return str
		},
		getlist(type) {
			if (this.typeshow1 == true) {
				var data = {
					date: this.date.result,
					type: this.lxtype[0].value
				}
			} else if (this.isdate == false) {
				this.$Request.get(this.$api.user.integralList).then(res => {
					if (type == 2) {
						this.recordList = this.recordList.concat(res.data.list)
					} else {
						this.recordList = res.data.list
						this.allpd = res.data.balance
					}
				});
			} else {
				var data = {
					date: this.date.result
				}
			}
			this.$Request.get(this.$api.user.integralList, data).then(res => {
				if (type == 2) {
					this.recordList = this.recordList.concat(res.data.list)
				} else {
					this.recordList = res.data.list
					this.allpd = res.data.balance
				}
			});
		}
	},
};
</script>

<style lang="scss" scoped>
.content {
	background: #262626 !important;
}

.neirongbox {
	width: 712rpx;
	height: 200rpx;
	background: rgba(255, 231, 192, 0.1);
	border-radius: 10rpx 10rpx 10rpx 10rpx;
	opacity: 1;
	border: 1rpx solid #FED187;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	margin-left: 23rpx;
	margin-top: 21rpx;
	color: #fff;

	.header-shoptxt {
		width: 710rpx;
		height: 100rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 18rpx;
		margin-left: 15rpx;

		.h_shoptxt {
			width: 580rpx;
			height: 52rpx;
			display: flex;
			justify-content: start;
			align-items: center;

			.shoptxt {
				width: 139rpx;
				height: 52rpx;
				background: #FFB02E;
				// border: 0px solid #0BF1FF;
				border-radius: 10px;
				text-align: center;
				line-height: 52rpx;
				color: white;
			}

			.sptitle {
				font-size: 28rpx;
				color: #fff;
				margin-left: 10px;
				width: 240rpx;
			}

			.sptitle-desc {
				font-size: 28rpx;
				color: #fff;
				margin-left: 15rpx;
				font-weight: bold;
			}

		}

		.sptitle-right {
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #fff;
			margin-right: 25rpx;
		}
	}

	.footer-timetxt {
		width: 710rpx;
		height: 100rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;

		.ft-create {
			margin-left: 15rpx;
		}

		.ft-blance {
			margin-right: 20rpx;
		}
	}

}

.header {
	display: flex;
	align-items: center;
}

.title {
	// text-align: center;
	padding: 20rpx 30rpx 0;
	font-size: 30rpx;
	font-weight: bold;
}

.datebox {
	width: 285rpx;
	height: 70rpx;
	background: #FFB02E;
	border-radius: 35px;
	text-align: center;
	line-height: 70rpx;
	margin-top: 35rpx;
	margin-left: 25rpx;
	color: #fff;
}

.gotuhg {
	margin-top: 35rpx;
	margin-right: 50rpx;
	font-weight: 500;
	color: #5F6B63;
}

.drboxtext {
	/* font-family: PingFang SC; */
	font-weight: bold;
	color: #fff;
	line-height: 98rpx;
	padding: 20rpx;
	display: flex;
	justify-content: space-between;
	align-items: center;
	width: 712rpx;
	height: 146rpx;
	background: rgba(255, 231, 192, 0.1);
	border-radius: 10rpx 10rpx 10rpx 10rpx;
	opacity: 1;
	border: 1rpx solid #FED187;
	margin-top: 28rpx;
	margin-bottom: 24rpx;
	margin: 28rpx 0 24rpx 20rpx;

	.blancetext {
		width: 208rpx;
		font-size: 14px;
		margin-left: 22rpx;
	}

}

.content {
	background: #fff;
	min-height: 100vh;
	padding-top: 20rpx;
}

.wain_top {
	width: 710rpx;
	background: #FFFFFF;
	margin: 0 auto;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20rpx;
	box-sizing: border-box;
	margin-bottom: 10rpx;
	border-bottom: 1px solid #BCBEBE;

	.left {
		display: flex;
		flex-direction: column;
		width: 100%;

		.bom {
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #282828;
		}

		view {
			padding: 0rpx 0 10rpx 0rpx;
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
		}

		view:nth-of-type(2) {
			display: flex;
			justify-content: space-between;
			align-items: center;

			text:nth-of-type(1) {
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
			}

			text:nth-of-type(2) {
				font-size: 30rpx;
				color: #333333;
				font-weight: 400;
				padding-left: 40rpx;
			}
		}
	}
}
</style>
